package com.myjar.excel.serializer;


import com.myjar.excel.util.IdentityHashMap;

import java.lang.reflect.Type;

/**
 * 在fastjson 中还定义了在android下的使用场景，这里简化掉了
 */

public final class SerializerConfig {

    // 存储cell单元实例化
    private static final IdentityHashMap<Type, ObjectSerializer> serializers = new IdentityHashMap<>();


    public static boolean put(Type type, ObjectSerializer value) {
        return serializers.put(type, value);
    }

    public static ObjectSerializer get(Type type) {
        return serializers.get(type);
    }


    // 目前只完成了基础的几种数据类型
    static  {
        put(Boolean.class, BooleanCodec.instance);
        put(Character.class, CharacterCodec.instance);
        put(Byte.class, ByteCodec.instance);
        put(Short.class, ShortCodec.instance);
        put(Integer.class, IntegerCodec.instance);
        put(Long.class, LongCodec.instance);
        put(Float.class, FloatCodec.instance);
        put(Double.class, DoubleCodec.instance);
        put(String.class, StringCodec.instance);
        put(Boolean.TYPE, BooleanCodec.instance);
        put(Character.TYPE, CharacterCodec.instance);
        put(Byte.TYPE, ByteCodec.instance);
        put(Short.TYPE, ShortCodec.instance);
        put(Integer.TYPE, IntegerCodec.instance);
        put(Long.TYPE, LongCodec.instance);
        put(Float.TYPE, FloatCodec.instance);
        put(Double.TYPE, DoubleCodec.instance);



//        put(BigDecimal.class, BigDecimalCodec.instance);
//        put(BigInteger.class, BigIntegerCodec.instance);

//        put(byte[].class, PrimitiveArraySerializer.instance);
//        put(short[].class, PrimitiveArraySerializer.instance);
//        put(int[].class, PrimitiveArraySerializer.instance);
//        put(long[].class, PrimitiveArraySerializer.instance);
//        put(float[].class, PrimitiveArraySerializer.instance);
//        put(double[].class, PrimitiveArraySerializer.instance);
//        put(boolean[].class, PrimitiveArraySerializer.instance);
//        put(char[].class, PrimitiveArraySerializer.instance);
//        put(Object[].class, ObjectArrayCodec.instance);
//        put(Class.class, MiscCodec.instance);

/*        put(SimpleDateFormat.class, MiscCodec.instance);
        put(Currency.class, new MiscCodec());
        put(TimeZone.class, MiscCodec.instance);
        put(InetAddress.class, MiscCodec.instance);
        put(Inet4Address.class, MiscCodec.instance);
        put(Inet6Address.class, MiscCodec.instance);
        put(InetSocketAddress.class, MiscCodec.instance);
        put(File.class, MiscCodec.instance);
        put(Appendable.class, AppendableSerializer.instance);
        put(StringBuffer.class, AppendableSerializer.instance);
        put(StringBuilder.class, AppendableSerializer.instance);
        put(Charset.class, ToStringSerializer.instance);
        put(Pattern.class, ToStringSerializer.instance);
        put(Locale.class, ToStringSerializer.instance);
        put(URI.class, ToStringSerializer.instance);
        put(URL.class, ToStringSerializer.instance);
        put(UUID.class, ToStringSerializer.instance);*/

        // atomic
        /*put(AtomicBoolean.class, AtomicCodec.instance);
        put(AtomicInteger.class, AtomicCodec.instance);
        put(AtomicLong.class, AtomicCodec.instance);
        put(AtomicReference.class, ReferenceCodec.instance);
        put(AtomicIntegerArray.class, AtomicCodec.instance);
        put(AtomicLongArray.class, AtomicCodec.instance);

        put(WeakReference.class, ReferenceCodec.instance);
        put(SoftReference.class, ReferenceCodec.instance);

        put(LinkedList.class, CollectionCodec.instance);*/
    }
}
